package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.dto.AdminSysMsgsDTO;
import org.linlinjava.litemall.admin.service.AdminSysMsgService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallSysMsg;
import org.springframework.web.bind.annotation.*;

@Api(tags = "系统消息模版API")
@RestController
@RequestMapping("/admin/sysmsg")
@RequiredArgsConstructor
public class AdminSysMsgController extends ResponseUtil {

    private final AdminSysMsgService adminSysMsgService;

    @ApiOperation("消息模版-「列表｜搜索」")
    @PostMapping("/sysMsgs")
    @LogAnno
    public Response sysMsgs(@RequestBody AdminSysMsgsDTO sysMsgsDTO){
        return adminSysMsgService.sysMsgs(sysMsgsDTO);
    }

    @ApiOperation("消息模版-「状态开关」")
    @ApiImplicitParam(name = "id",value = "id")
    @GetMapping("/status")
    @LogAnno
    public Response status(@RequestParam("id")Integer id){
        return adminSysMsgService.status(id);
    }

    @ApiOperation("消息模版-「编辑信息」")
    @PostMapping("/edit")
    @LogAnno
    public Response edit(@RequestBody LitemallSysMsg sysMsg){
        return adminSysMsgService.edit(sysMsg);
    }

}
